<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./test.js"></script>
</head>

<body>
  <h3 id="txt"></h3>
  <input type="text" id='inputTxt' oninput="changeMsg(this.value)">
  
  
  
  <!-- <script>
    let txt = document.getElementById('txt')
    let inputTxt = document.getElementById('inputTxt')
    let _msg = "aaa"
    let data = {}
    Object.defineProperty(data, 'msg', {
      get() {
        return _msg
      },
      set(newVal) {
        _msg = newVal
        txt.innerHTML=_msg
      }
    })
    function changeMsg(value) {
      data.msg=value //赋值操作触发set方法
    }
    txt.innerHTML=_msg


  </script> -->
</body>

</html>